import load
import event2
import help
import load2

class student:
    def __init__(self,name):
        self.name=name
        self.havePhone=True
        self.money=0
        self.baoguang=False
        self.qiming=False
        self.lihun=False
        self.ispeiqian=False
        self.iskaoshi=False
        self.huaiyun=False
        self.renshixiaoz=False
        self.cp=[]
        self.t=3
        self.haveSon=0
        self.fanzui=0
        self.beihai=0
        self.jiaoyu=0
        self.papa=0
        self.beipa=0
        self.room=load2.findRoom(self.name)

    def toCsv(self):
        return str(self.name)+','+str(self.shuxue)+','+str(self.jisuan)+','+str(self.huaxue)+','+str(self.zhiwu)+','+ \
               str(self.zhuanye)+','+str(self.sixiu)+','+ str(self.tiyu)+','+str(self.yingyu)+','+str(self.yuwen)+','+ \
               str(self.gpa)+','+str(self.money)

    def toStr(self):
        r=self.name

        if self.havePhone:
            r+='有手机；'
        else:
            r+='没有手机；'


        if self.renshixiaoz:
            r+='认识校长；'
        else:
            r+='不认识校长；'

        r += '有' + str(self.money) + '块钱；'

        if self.haveSon>0:
            r += '有' + str(self.haveSon) + '个孩子；'

        if self.fanzui>0:
            r += '进行犯罪' + str(self.fanzui) + '次；'
        if self.beihai>0:
            r += '遭受犯罪侵害' + str(self.beihai) + '次；'
        if self.papa>0:
            r += '啪别人' + str(self.papa) + '次；'
        if self.beipa>0:
            r += '被啪' + str(self.beipa) + '次；'
        if self.jiaoyu>0:
            r += '收容教育共' + str(self.jiaoyu) + '天；'

        if len(self.cp)>0:
            r+='有女朋友'
            for i in self.cp:
                r+=i

        return r

    def getAll(self):
        print('这个时候的'+s.name+self.toStr())
        print(self.toCsv())

allStudent=[]

for i in range(1,load.l):
    itname = load.getCell(i, load.name)
    if load2.isDead(itname):
        continue
    s=student(itname)
    s.shuxue=load.getCell(i,load.shuxue)
    s.jisuan=load.getCell(i,load.jisuan)
    s.huaxue=load.getCell(i,load.huaxue)
    s.zhiwu=load.getCell(i,load.zhiwu)
    s.zhuanye=load.getCell(i,load.zhuanye)
    s.sixiu=load.getCell(i,load.sixiu)
    s.tiyu=load.getCell(i,load.tiyu)
    s.yingyu=load.getCell(i,load.yingyu)
    s.yuwen=load.getCell(i,load.yuwen)
    s.gpa=load.getCell(i,load.gpa)
    s.money=load.getCell(i,load.money)
    allStudent.append(s)

def randomEvent():
    return help.randInList(event2.allEvent)

def doit(s):
    if not s.t<=0:
        print(s.name + '：')
    else:
        print(s.name + '：暂无人身自由')
        return
    while s.t>0:
        e=randomEvent()
        r=e(s,allStudent)
        if not (r is None):
            print(r+'\n')

dolist=[]
for s in load2.allRoom['下安桃山公寓315']:
    dolist.append(help.nameToObj(s,allStudent))
dolist.append(help.nameToObj('林夜弦',allStudent))

def inspect(s):
    if s.huaiyun:
        s.t -= 3
        s.huaiyun=False
        s.haveSon+=1
        print(s.name+'的第'+str(s.haveSon)+'个孩子已经在校医院顺利生产！')
        return
    if s.tiyu<=0:
        s.t -= 3
        if help.touzi():
            s.tiyu += 55
        else:
            s.tiyu += 10
        print(s.name + '的体育成绩过低，正在校医院接受教育')
        s.jiaoyu += 1
        return
    if s.sixiu<=0:
        s.t -= 3
        if help.touzi():
            s.sixiu += 80
        else:
            s.sixiu += 40
        print(s.name + '的思修成绩过低，正在校警看守所接受教育')
        s.jiaoyu += 1
        return

def getInfo(two=True):
    for s in allStudent:
        print(s.toStr())
    if two:
        for s in allStudent:
            print(s.toCsv())

getInfo(False)

m=5
d=1
while True:
    if m==6 and d==1:
        break
    else:
        print('\n'+str(m) + '月' + str(d) + '日，')
        for s in allStudent:
            s.t=3
            inspect(s)
        for s in dolist:
            doit(s)
        d+=1
        if d==32:
            d=1
            m+=1

getInfo()